package zjc.案例练习;

import java.util.Scanner;

public class 买飞机票 {
    public static void main(String[] args) {
        Scanner sr = new Scanner(System.in);
        System.out.println("请输入机票的原价:");
        double price = sr.nextDouble();
        System.out.println("请输入几月份的飞机");
        int month = sr.nextInt();
        System.out.println("您需要经济舱还是头等舱");
        String zhonglei = sr.next();
        price = m(month, price, zhonglei);
        if (price == -2) {
            System.out.println("您输入的月份有问题");
        } else if (price != -1) {
            System.out.println("您的飞机票价格为" + price);
        }


    }
    public static double m(int month, double price, String zhonglei){
        if(month>=5&&month<=10){
            switch(zhonglei){
                case "经济舱": price*=0.85;break;
                case "头等舱": price*=0.9;break;
                default:
                    System.out.println("您输入的票的类型错误");return -1;
            }
        }else if((month<5&&month>0)||(month>10&&month<=12)){
            switch(zhonglei){
                case "经济舱": price*=0.65;break;
                case "头等舱": price*=0.7;break;
                default:
                    System.out.println("您输入的票的类型错误");return -1;
            }
        }else{
            return -2;
        }
        return price;
    }
}
